package com.jago.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ReadServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();
        String username = (String) servletContext.getAttribute("username");
        String url = servletContext.getInitParameter("url");
        resp.getWriter().println(username + url);
        RequestDispatcher dispatcher = servletContext.getRequestDispatcher("/hello");
        dispatcher.forward(req, resp);
    }
}
